public class Main {
    public static void main(String[] args) {
        int n = 3; // 圆盘的数量
        hanoi(n, 'A', 'B', 'C'); // A, B, C是三根柱子的标识
    }

    // 递归方法，解决汉诺塔问题
    public static void hanoi(int n, char from, char to, char aux) {
        if (n == 1) {
            System.out.println("Move disk 1 from " + from + " to " + to);
            return;
        }
        // 将n-1个圆盘从from移动到aux
        hanoi(n - 1, from, aux, to);
        // 将最大的圆盘从from移动到to
        System.out.println("Move disk " + n + " from " + from + " to " + to);
        // 将n-1个圆盘从aux移动到to
        hanoi(n - 1, aux, to, from);
    }
}